package com.example.demo.controller;


import com.example.demo.pojo.Clazz;
import com.example.demo.pojo.Result;
import com.example.demo.service.ClazzService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin
public class ClazzController {
    @Resource
    private ClazzService clazzService;


    /**
     * 查找所有有班级
     **/
    @GetMapping("/clazz")
    public Result getAllClazz() {
        List<Clazz> clazzList = clazzService.getAllClazz();
        return Result.success(clazzList);
    }
    /**
     * 查找班级下面的学生
     */
    @GetMapping("/clazzStudent/{id}")
    public Result getClazzStudent(@PathVariable Integer id) {
        List<Clazz> clazzList = clazzService.getClazzStudent(id);
        return Result.success(clazzList);
    }
    /**
     * 分步查询班级下面的学生
     */
    @GetMapping("clazzStudentStep2/{cid}")
    public Result getClazzStudentStep2(@PathVariable Integer cid) {
        List<Clazz> clazzList = clazzService.getClazzStudent(cid);
        return Result.success(clazzList);


    }

}
